import config from "./config"
import tool from './utils/tool'

import NumberInput from './components/NumberInput'
import NumberRangeInput from './components/NumberRangeInput'
import DataRangePicker from './components/DcDataRangePicker'

import errorHandler from './utils/errorHandler'

import SvgIcon from '@/components/SvgIcon'

import * as elIcons from '@element-plus/icons-vue'
import * as scIcons from './assets/icons'


export default {
	install(app) {
		//挂载全局对象
		app.config.globalProperties.$CONFIG = config;
		app.config.globalProperties.$TOOL = tool;


		//注册全局组件
		app.component('NumberInput', NumberInput);
		app.component('NumberRangeInput', NumberRangeInput);
		app.component('DataRangePicker', DataRangePicker);
		
		//注册全局指令
		
		app.component('SvgIcon', SvgIcon)
		//统一注册el-icon图标
		for(let icon in elIcons){
			// 兼容老版本图标使用
			app.component(`ElIcon${icon}`, elIcons[icon])

			// 注册element-plus图标组件
			const componentConfig = elIcons[icon];
			app.component(componentConfig.name, componentConfig);
		}
		//统一注册sc-icon图标
		for(let icon in scIcons){
			app.component(`ScIcon${icon}`, scIcons[icon])
		}

		//关闭async-validator全局控制台警告
		window.ASYNC_VALIDATOR_NO_WARNING = 1

		//全局代码错误捕捉
		app.config.errorHandler = errorHandler
	}
}
